From 075c8d1624d4d9b6ef8a680697027c358420ebfc Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 23 Jul 2010 10:15:29 +0000 Subject: [PATCH] Followup to r69776: cache result of extractRequestParams() because it gets called 2 or 3 times per module per request now. Also touch up documentation here and there --- includes/api/ApiBase.php | 14 ++++++++------ includes/api/ApiQuery.php | 1 + includes/api/ApiQueryBase.php | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 19779d40f0..09c9f45bf4 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -479,16 +479,18 @@ abstract class ApiBase { * @return array */ public function extractRequestParams( $parseLimit = true ) { - $params = $this->getFinalParams(); - $results = array(); + if ( !isset( $this->mCachedRequestParams ) ) { + $params = $this->getFinalParams(); + $this->mCachedRequestParams = array(); - if ( $params ) { // getFinalParams() can return false - foreach ( $params as $paramName => $paramSettings ) { - $results[$paramName] = $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit ); + if ( $params ) { // getFinalParams() can return false + foreach ( $params as $paramName => $paramSettings ) { + $this->mCachedRequestParams[$paramName] = $this->getParameterFromSettings( $paramName, $paramSettings, $parseLimit ); + } } } - return $results; + return $this->mCachedRequestParams; } /** diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index b86438f108..cb7080df5c 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -489,6 +489,7 @@ class ApiQuery extends ApiBase { /** * Create a generator object of the given type and return it + * @param $generatorName string Module name */ public function newGenerator( $generatorName ) { // Find class that implements requested generator diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 1a2ddcc96e..c787dd912d 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -47,8 +47,9 @@ abstract class ApiQueryBase extends ApiBase { } /** - * Get the cache mode for the data generated by this module. Override this - * in the module subclass. + * Get the cache mode for the data generated by this module. Override + * this in the module subclass. For possible return values and other + * details about cache modes, see ApiMain::setCacheMode() * * Public caching will only be allowed if *all* the modules that supply * data for a given request return a cache mode of public. -- 2.20.1